﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Routing;
using Gecko.Services;

namespace Gecko.Controllers
{
    public class ShortWaterLeakController : ApiController
    {
        // GET api/shortwaterleak
        public object Get(double lat, double lon)
        {
            using (var waterLeakService = new WaterLeakService())
            {
                var result = waterLeakService.GetShortWaterLeak(lat, lon);
                foreach (var item in result)
                {
                    var urlHelper = new UrlHelper(Request);
                    if (!String.IsNullOrEmpty(item.Image))
                    {
                        item.Image = urlHelper.Link("DefaultApi", new { controller = "LeakContent", id = item.Image });
                    }else
                    {
                        item.Image = "";
                    }
                }
                return new { Data = result };
            }
        }

        // GET api/shortwaterleak/5
        public string Get(int id)
        {
            return "value";
        }

        // POST api/shortwaterleak
        public void Post([FromBody]string value)
        {
        }

        // PUT api/shortwaterleak/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/shortwaterleak/5
        public void Delete(int id)
        {
        }
    }
}
